from django.shortcuts import render, redirect
from .models import Contact
from django.views import View


# Create your views here.
class ContactView(View):
    """首页信息"""

    def get(self, request):

        return render(request, 'contact.html')

    def post(self, request):
        # 接收参数
        name = request.POST.get('Name', '')
        email = request.POST.get('Email', '')
        subject = request.POST.get('Subject', '')
        content = request.POST.get('Message', '')

        Contact.objects.create(
            name=name,
            email=email,
            subject=subject,
            content=content,
        )
        return render(request, 'contact.html')
